package ccm.itesm.mx.servicios;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.os.Bundle;
import android.util.AttributeSet;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class MuestraCalificaciones extends Activity {

	
	private ArrayList<String> nombreMaterias;
	private ArrayList<String> nombreProfesores;
	private ArrayList<String> parcial1;
	private ArrayList<String> parcial2;
	private ArrayList<String> parcial3;
	private ArrayList<String> parcial5;
	private ListView maListViewPerso;
	TextView profesor;
	TextView materia;
	TextView calP1;
	TextView calP2;
	TextView calP3;
	TextView calProm;
	TextView calFinal;
	
	/* (non-Javadoc)
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.listamaterias);
		Bundle b = this.getIntent().getExtras();
		nombreMaterias = b.getStringArrayList("materias");
		nombreProfesores = b.getStringArrayList("profesores");
		parcial1 = b.getStringArrayList("p1");
		parcial2 = b.getStringArrayList("p2");
		parcial3 = b.getStringArrayList("p3");
		parcial5 = b.getStringArrayList("p5");
		System.out.println(nombreMaterias.get(b.getInt("clic")));
		maListViewPerso = (ListView) findViewById(R.id.listviewperso);
		ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>();
		HashMap<String, String> map;
		
		
			 map = new HashMap<String, String>();
			 map.put("materia",nombreMaterias.get(b.getInt("clic")) );
			 listItem.add(map);

			 map = new HashMap<String, String>();
			 map.put("materia",nombreProfesores.get(b.getInt("clic")));
			 listItem.add(map);
			 
			 map = new HashMap<String, String>();
			 map.put("materia","Parcial 1");
			 if(!parcial1.get(b.getInt("clic")).contains("null")){
				 map.put("calificacion",parcial1.get(b.getInt("clic")) );
			 }else{
				 map.put("calificacion","N/A");
			 }
			 listItem.add(map);
			 
             map = new HashMap<String, String>();
			 map.put("materia","Parcial 2");
			 if(!parcial2.get(b.getInt("clic")).contains("null")){
				 map.put("calificacion",parcial2.get(b.getInt("clic")) );
			 }else{
				 map.put("calificacion","N/A");
			 }
			 listItem.add(map);
			 
			 map = new HashMap<String, String>();
			 map.put("materia","Parcial 3");
			 if(!parcial3.get(b.getInt("clic")).contains("null")){
				 map.put("calificacion",parcial3.get(b.getInt("clic")) );
			 }else{
				 map.put("calificacion","N/A");
			 }
			 listItem.add(map);
			 
			 map = new HashMap<String, String>();
			 map.put("materia","Final");
			 if(!parcial5.get(b.getInt("clic")).contains("null")){
				 map.put("calificacion",parcial5.get(b.getInt("clic")) );
			 }else{
				 map.put("calificacion","N/A");
			 }
			 listItem.add(map);
			 
		 SimpleAdapter mSchedule = new SimpleAdapter (this.getBaseContext(), listItem, R.layout.item1,
	               new String[] {"materia", "calificacion"}, new int[] {R.id.materia, R.id.calificacion});
	 
	        maListViewPerso.setAdapter(mSchedule);
		
		/*
		
		
		materia = (TextView)findViewById(R.id.textView1);
		materia.setText(nombreMaterias.get(b.getInt("clic")));
		
		profesor = (TextView)findViewById(R.id.textView2);
		profesor.setText(nombreProfesores.get(b.getInt("clic")));
				
		calP1 = (TextView)findViewById(R.id.textView4);
		calP1.setText(parcial1.get(b.getInt("clic")));
		
		calP2 = (TextView)findViewById(R.id.textView6);
		calP2.setText(parcial2.get(b.getInt("clic")));
		
		calP3 = (TextView)findViewById(R.id.textView8);
		calP3.setText(parcial3.get(b.getInt("clic")));
		calP3.setText("NA");
		
		calProm = (TextView)findViewById(R.id.textView10);
		int promedio = (Integer.parseInt((parcial1.get(b.getInt("clic")))) + Integer.parseInt((parcial2.get(b.getInt("clic"))))) / 2 ;
		calProm.setText(" " + promedio);
		
		calFinal = (TextView)findViewById(R.id.textView12);
		System.out.println("TAAAAAAAAM " + (parcial5.get(b.getInt("clic"))));
		
		
		calFinal.setText("NA");
		
		*/
	}

	
	
}
